<script type="text/javascript">
menuLayers.show = function(id, controller, objid, objname, e) {
    var mnu = document.getElementById? document.getElementById(id): null;
    if (!mnu) return;
    this.activeMenuID = id;
    if ( mnu.onmouseout == null ) mnu.onmouseout = this.mouseoutCheck;
    if ( mnu.onmouseover == null ) mnu.onmouseover = this.clearTimer;
    viewport.getAll();
    rewritePopupContent(controller, objid, objname);

    this.position(mnu,e);
}
</script>

<script>
function confirmAndDelete(url) {
	if (confirm("Adakah Anda Pasti?")) {
		location = url
	}
	
}


function rewritePopupContent(controller, objid, objname) {
    $('popmenu').style.width = 180;
    $('popmenu').innerHTML = "<ul>" + 
					       "<li><a href=\""  + "?act=view_sek&" + "institusi_id=" + objid + "\">&nbsp;&nbsp;Papar Maklumat Institusi</a>" + 

					       "<li><a href=\""  + "?act=edit_sek&" + "institusi_id=" + objid + "\">&nbsp;&nbsp;Edit Maklumat Institusi</a>" + 

<?
if ($_SESSION['ACCESS_LEVEL'] != '5') {
?>
					       "<li><a href=\"javascript: confirmAndDelete('?act=delete_sek&institusi_id=" + objid + "')" + "\">&nbsp;&nbsp;Hapus Rekod Institusi</a>" + 
<? } ?>
					       "<hr size=1><li><a href=\""  + "?act=list_kelas&" + "institusi_id=" + objid + "\">&nbsp;&nbsp;Senarai Kelas</a>" + 
					       "<li><a href=\""  + "?act=list_murid&" + "institusi_id=" + objid + "\">&nbsp;&nbsp;Senarai Murid</a>" + 
					       "<li><a href=\""  + "?act=list_guru&"  + "institusi_id=" + objid + "\">&nbsp;&nbsp;Senarai Guru/Staff</a>" + 
					       "</ul>"
     
}

function a(id) {
	MM_openBrWindow('/course_implementations/show_timetable2/'+id,'','scrollbars=yes,width=1000,height=600')
}
</script>

<script>
function getAjaxDaerah() {
	//$('item_selection').innerHTML = "<font color=orange>Searching Items...please wait</font>"
	ajax_department_request("ajax.php?act=daerahs_of_negeri", "negeri_id="+$("select_negeri").value)
}

function ajax_department_request(url, data) {
    var myAjax = new Ajax.Request(
        url,
        {method: 'post', parameters: data, onComplete: ajax_department_response}
    );
}

function ajax_department_response(originalRequest) {
	if (originalRequest.responseText != 0) {
		var a = originalRequest.responseText.split("$$")
		var k = new Array(a.length)
		for (i=0; i<k.length; i++) {
			k[i] = a[i].split("=")
		}
		//alert(originalRequest.responseText)
		
		str  = "<select  id=\"select_ppd\" name=\"d\" class=\"px200\" onchange=\"//getAjaxSubItem()\">\n";
		str += "<option value=\"\">--Semua Daerah--</option>\n"
		for (i=0; i<k.length; i++) {
			str += "<option value=\"" + k[i][1] + "\">" + k[i][0] + "</option>\n";
		}
		str += "</select>\n";
		$("select_ppd_span").innerHTML = str;
	}
	else {
		$('select_ppd_span').innerHTML = "<font color=orange>List not found</font>"
	}
}
</script>

        
        <div id="content">
            <div id="content_header" class="size_20" style=" border-bottom-width:medium; border-bottom-style:solid; border-bottom-color:#777777">
            	<img src="images/icn_mytaskTitle.gif" align="absmiddle" width="" height=""> Projek </div>
        	<div id="content_bgblue">
                <div id="content_bgwhite">
        
<div id="kandungan" style="border: 0pt solid silver; width: 100%;">

            <? alert_some_message()?>


<form name="search" action="?act=search_sek" method="POST" target="" onSubmit="" onReset="">
<fieldset style="background:#ffffff; border-width:thin; border-style:solid; padding:10px; border-color:#CCCCCC;">
<legend style="font-size:1.0em; font-weight: bold;">Carian </legend>

<table border="0" cellpadding="4" cellspacing="1" width="100%">
  <tbody>
    <tr id="SkimRow" style="display: ;">
      <td class="TableField" width="8"><font class="ErrorMessage"></font></td>
      <td class="TableField" width="150">Negeri</td>
      <td class="TableField" width="18">:</td>
      <td class="TableRowLeft" width="487"><span class="classRow">
        <select name="n" id="select_negeri" onchange="getAjaxDaerah()">
          <option value="">--Semua Negeri--</option>
          <?
				$combo   = new GUI();
				$options = getOptionsFromTable('ref_negeri','id','negeri');
				
				
				if ($_SESSION['ACCESS_LEVEL'] == '5') {
					echo $combo->printCombo2($options, "",false, $institusi->negeri_id,false,0);
				}
				else {		
					echo $combo->printCombo2($options, "",false, $_REQUEST['n'],false,0);
				}
			  ?>
        </select>
      </span></td>
    </tr>
    <tr id="JenisBantuanRow" style="display: ;">
      <td class="TableField" width="8">&nbsp;</td>
      <td class="TableField" width="150">Daerah</td>
      <td class="TableField" width="18">:</td>
      <td class="TableRowLeft" width="487"><span class="classRow" id="select_ppd_span">
        <select name="d" id="select_ppd">
          <option value="">--Semua Daerah--</option>
          <?
				$combo   = new GUI();
				//print_r($options);
				if ($_SESSION['ACCESS_LEVEL'] == '5') {
					$options = getOptionsFromTableWithConds('ref_daerah','id','daerah',"WHERE negeri_id=$institusi->negeri_id");
					echo $combo->printCombo2($options, "",false, $institusi->kod_ppd,false,0);
				}else {
					$options = getOptionsFromTableWithConds('ref_daerah','id','daerah',"WHERE negeri_id=$_REQUEST[n]");
					echo $combo->printCombo2($options, "",false, $_REQUEST['d'],false,0);
				}
			  ?>
        </select>
      </span></td>
    </tr>
    <tr id="NegeriRow" style="">
      <td class="TableField" width="8">&nbsp;</td>
      <td class="TableField" width="150">Kategori </td>
      <td class="TableField" width="18">:</td>
      <td class="TableRowLeft" width="487"><select name="a" id="select" onchange="">
        <option value="">--Semua Kategori--</option>
        <?
				$combo   = new GUI();
				if ($_SESSION['ACCESS_LEVEL'] == '5') {
					$options = getOptionsFromTable('project_categories','id','name');
					echo $combo->printCombo2($options, "",false, $institusi->agensi_pelaksana_id,false,0);
				}else {
					$options = getOptionsFromTable('project_categories','id','name');
					echo $combo->printCombo2($options, "",false, $_REQUEST['d'],false,0);
				}
			  ?>
      </select>
          <!--input name="prasekolah" type="checkbox" value="t" checked="checked" />
      Prasekolah -->
      </td>
    </tr>
    <tr id="NegeriRow" style="">
      <td class="TableField" width="8">&nbsp;</td>
      <td class="TableField" width="150">Kementerian </td>
      <td class="TableField" width="18">:</td>
      <td class="TableRowLeft" width="487"><select name="a" id="select" onchange="">
        <option value="">--Semua Kementerian--</option>
        <?
				$combo   = new GUI();
				if ($_SESSION['ACCESS_LEVEL'] == '5') {
					$options = getOptionsFromTable('kementerian','id','name');
					echo $combo->printCombo2($options, "",false, $institusi->agensi_pelaksana_id,false,0);
				}else {
					$options = getOptionsFromTable('kementerian','id','name');
					echo $combo->printCombo2($options, "",false, $_REQUEST['d'],false,0);
				}
			  ?>
      </select>
          <!--input name="prasekolah" type="checkbox" value="t" checked="checked" />
      Prasekolah -->
      </td>
    </tr>
    <tr id="NegeriRow" style="">
      <td class="TableField" width="8">&nbsp;</td>
      <td class="TableField" width="150">Projek Jabatan </td>
      <td class="TableField" width="18">:</td>
      <td class="TableRowLeft" width="487"><select name="a" id="select" onchange="">
        <option value="">--Semua Jabatan--</option>
        <?
				$combo   = new GUI();
				if ($_SESSION['ACCESS_LEVEL'] == '5') {
					$options = getOptionsFromTable('project_departments','id','name');
					echo $combo->printCombo2($options, "",false, $institusi->agensi_pelaksana_id,false,0);
				}else {
					$options = getOptionsFromTable('project_departments','id','name');
					echo $combo->printCombo2($options, "",false, $_REQUEST['d'],false,0);
				}
			  ?>
      </select>
          <!--input name="prasekolah" type="checkbox" value="t" checked="checked" />
      Prasekolah -->
      </td>
    </tr>
    <tr id="NegeriRow" style="">
      <td class="TableField" width="8">&nbsp;</td>
      <td class="TableField" width="150">Status </td>
      <td class="TableField" width="18">:</td>
      <td class="TableRowLeft" width="487"><select name="s" id="select" onchange="">
        <option value="">--Semua Status--</option>
        <?
				$combo   = new GUI();
				if ($_SESSION['ACCESS_LEVEL'] == '5') {
					$options = getOptionsFromTable('project_statuses','id','name');
					echo $combo->printCombo2($options, "",false, $institusi->project_status_id,false,0);
				}else {
					$options = getOptionsFromTable('project_statuses','id','name');
					echo $combo->printCombo2($options, "",false, $_REQUEST['s'],false,0);
				}
			  ?>
      </select>
          <!--input name="prasekolah" type="checkbox" value="t" checked="checked" />
      Prasekolah -->
      </td>
    </tr>
    <tr id="SkimRow" style="display: ;">
      <td class="TableField" width="8"><font class="ErrorMessage"></font></td>
      <td class="TableField" width="150">Nama Projek </td>
      <td class="TableField" width="18">:</td>
      <td class="TableRowLeft" width="487"><input type="text" name="q" value="<? echo ($_SESSION['ACCESS_LEVEL'] == '5')? $institusi->nama:$_REQUEST['q'];?>" size="40" /></td>
    </tr>
    <tr class="NormalTextLeft">
      <td colspan="4" align="center"><span class="TableRowLeft">
        <input name="button" type="submit" onclick="" value="Cari" style=" width:100px;" />
      </span></td>
    </tr>
  </tbody>
</table>
</fieldset>

<br>
</form>

<? if ($res_count > 0) {?>

<table width="100%" border="0" cellspacing="1" cellpadding="2">
              <tr>
                <td align="left" scope="col" style=" font-weight:bold; border-bottom-style:solid; border-bottom-width:thin;">Hasil Carian  : <?=$total_count?> Projek </td>
              </tr>
        </table>
			
			<br/>
            <font class="NormalTextLeft">
            
                <li>&nbsp;Isihan <i>default</i> senarai adalah pada lajur Nama.  
                </li><li>&nbsp;Klik pada lajur yang hendak diisih.
                
                        </li>
                <li>&nbsp;Klik pada Nama Projek untuk paparan butir-butir selanjutnya.</li>
                    
            </font>
<br>
<br>
<div style=" overflow: ;">
  <table width="100%" border="0" cellspacing="1" cellpadding="2">
    <tr>
      <td align="right"><a href="export.jsp?act=<?=$act?>2&<?=$paginate_str?>" title="Eksport Senarai Ini"><img src="images/excel.gif"></a></td>
      <td width="20" align="left"><? if ($_REQUEST['p'] > 1) {?><a href="?act=search_sek&<?=$paginate_str?>&p=<?=$page-1?>"><b style=" font-size:1.5em">&laquo;</b></a><? } ?></td>
      <td width="60" align="right"><select name="select2" size="0" onblur="" onchange="location='?act=search_sek&<?=$paginate_str?>&p='+this.value" onfocus="">
          <?
for ($face=($page-5);$face<($page+5);$face++) {
	if ($face > $last_page) break;
	if ($face < 1) continue;
	$selected = '';
	if ($face == $page) {
		$selected = "selected";
	}
	else {
		$selected = "";
	}
?>
          <option value="<?=$face?>" <?=$selected?>>Muka
            <?=$face?>
            </option>
          <? } ?>
        </select>
      </td>
      <td width="20" align="right"><? if ($_REQUEST['p'] < $last_page) {?><a href="?act=search_sek&<?=$paginate_str?>&p=<?=$page+1?>"><b style=" font-size:1.5em">&raquo;</b></a><? } ?></td>
    </tr>
  </table>
  <table width="100%" border="0" cellspacing="1" cellpadding="2" style=" border:thin; border-color:#CCCCCC; border-style:solid;">
    <tr>
      <td width="20" align="center" bgcolor="#999999" scope="col"><span class="style3">Bil</span></td>
      <td align="center" bgcolor="#999999" scope="col"><span class="style3">Nama Projek </span></td>
      <td align="center" bgcolor="#999999" scope="col"><span class="style3">Negeri</span></td>
      <td align="center" bgcolor="#999999" scope="col"><span class="style3">Daerah</span></td>
      <td align="center" bgcolor="#999999" scope="col"><span class="style3">Kategori</span></td>
      <td align="center" bgcolor="#999999" scope="col">Kementerian</td>
      <td align="center" bgcolor="#999999" scope="col"><span class="style3">Status</span></td>
      <td width="30" align="center" bgcolor="#999999" scope="col">&nbsp;</td>
    </tr>
    <?
$even = true; 
$i = ($page-1)*20;
$i=0;
while ($dat = pg_fetch_object($res)) {
	$i++;
	$even = !$even;
	$bgcolor = ($even)? "":"#E9F0F5";
?>
    <tr bgcolor="<?=$bgcolor?>" onmouseover="this.style.background='#FFFFCC'" onmouseout="this.style.background='<?=$bgcolor?>'" onmousedown="menuLayers.show('popmenu','index.jsp?act=', '<?=$dat->institusi_id?>', 'KPPT(PENDAKWAAN)', event)">
      <td><?=$i?>
        .</td>
      <td><?=strtoupper($dat->nama)?></td>
      <td><?=$dat->negeri_id?></td>
      <td><?=$dat->ppd?></td>
      <td style=" width:150px; overflow:scroll; height:20px;"><?=$dat->ppd?></td>
      <td align="center"><span style=" width:150px; overflow:scroll; height:20px;">
        <?=$dat->ppd?>
      </span></td>
      <td><? echo ($dat->aktif=='t')? "Aktif":"Tidak Aktif"; ?></td>
      <td align="center">&nbsp;</td>
    </tr>
    <? } ?>
  </table>
  <table width="100%" border="0" cellspacing="1" cellpadding="2">
    <tr>
      <td align="right"></td>
      <td width="20" align="left"><? if ($_REQUEST['p'] > 1) {?>
          <a href="?act=search_sek&amp;<?=$paginate_str?>&amp;p=<?=$page-1?>"><b style=" font-size:1.5em">&laquo;</b></a>
        <? } ?></td>
      <td width="60" align="right"><select name="select" size="0" onblur="" onchange="location='?act=search_sek&amp;<?=$paginate_str?>&amp;p='+this.value" onfocus="">
          <?
for ($face=($page-5);$face<($page+5);$face++) {
	if ($face > $last_page) break;
	if ($face < 1) continue;
	$selected = '';
	if ($face == $page) {
		$selected = "selected";
	}
	else {
		$selected = "";
	}
?>
          <option value="<?=$face?>" <?=$selected?>>Muka
            <?=$face?>
          </option>
          <? } ?>
        </select>
      </td>
      <td width="20" align="right"><? if ($_REQUEST['p'] < $last_page) {?>
          <a href="?act=search_sek&amp;<?=$paginate_str?>&amp;p=<?=$page+1?>"><b style=" font-size:1.5em">&raquo;</b></a>
        <? } ?></td>
    </tr>
  </table>
</div>

<table width="100%" border="0" cellspacing="1" cellpadding="2">
  <tr>
    <td>&nbsp;</td>
    <td width="20" align="left"><a href="?act=list_sek&p=<?=$_REQUEST['p']-1?>"></a></td>
    <td align="right" width="100">&nbsp;</td>
    <td width="20" align="right"><a href="?act=list_sek&p=<?=$_REQUEST['p']+1?>"></a></td>
  </tr>
</table>
<!--/fieldset-->
<? }
else {
	if (!empty($_REQUEST['q'])) {
		echo "Tiada hasil carian.";	
	}
}
 // end of search result list?>

</div>
<!--div id="content_footborder" style="width:930px; position:absolute; left:0; background:#ccccff; text-align:center">
  &copy; Kementerian Pelajaran Malaysia, 2010.
 </div-->
</div>
<!-- close content_bgwhite -->
</div>
<!-- close content_bgblue -->
</div>
<!-- close content -->

</div>
<!-- close container_content -->

</div>
<!-- close container -->
</body>

<!-- popup menu initial layer----->
<div id="popmenu" class="menu"></div>
<!-- EOpopup menu initial layer----->
